%   FORMAT OF THE SUBSETTED FILE
%     
%     ITEMS                      FORMAT   
%      
%  1 Year                          I4        
%  2 Day                           I4        
%  3 Hour                          I3        
%  4 Minute                        I3        
%  5 BX, nT (GSE, GSM)             F8.2      
%  6 BY, nT (GSM)                  F8.2      
%  7 BZ, nT (GSM)                  F8.2      
%  8 Speed, km/s                   F8.1      
%  9 Electric field, mV/m          F7.2      
% 
% This file was produced by  FTPBrowser service

temp = load('D:\Manoj\ace\omni_5min_6340.lst');
fday = datenum(temp(:,1),0,0,temp(:,3),temp(:,4),30)+temp(:,2)-datenum(2000,1,1);
% data are averagrages at center of minutes
%9999.99 9999.99 9999.99 99999.9 999.99
L = temp(:,5) == 9999.99 | temp(:,6) == 9999.99 |...
    temp(:,7) == 9999.99 | temp(:,8) == 99999.9 |temp(:,9) == 999.99;
temp(L,:) = [];
fday(L) = [];
bt=sqrt(temp(:,6).^2+temp(:,7).^2); %SQRT(By.^2+Bz.^2)
angl = acos(temp(:,7)./bt);
% L = imag(angl) ~= 0;
% angl(L) = 0;
Em = (temp(:,8).*bt.*(sin(angl./2)).^2.*1e-3);
ace_gsm_bz = temp(:,7);
clear temp bt L angl;

ace_all(:,1) = fday;
ace_all(:,2) = Em;
save c:\manoj\projects\ace\Em ace_all ace_gsm_bz;


